/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.klikmee.sms.core.model;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 
 * @author makcro
 */
@Entity
@Table(name = "service")
@NamedQueries({
		@NamedQuery(name = "Service.findAll", query = "SELECT s FROM Service s"),
		@NamedQuery(name = "Service.findById", query = "SELECT s FROM Service s WHERE s.id = :id"),
		@NamedQuery(name = "Service.findByMTSShortCode", query = "SELECT s FROM Service s WHERE s.mTSShortCode = :mTSShortCode"),
		@NamedQuery(name = "Service.findByVIPShortCode", query = "SELECT s FROM Service s WHERE s.vIPShortCode = :vIPShortCode"),
		@NamedQuery(name = "Service.findByTelenorShorCode", query = "SELECT s FROM Service s WHERE s.telenorShorCode = :telenorShorCode"),
		@NamedQuery(name = "Service.findByDesctiption", query = "SELECT s FROM Service s WHERE s.desctiption = :desctiption"),
		@NamedQuery(name = "Service.findBySintax", query = "SELECT s FROM Service s WHERE s.sintax = :sintax"),
		@NamedQuery(name = "Service.findByServiceType", query = "SELECT s FROM Service s WHERE s.serviceType = :serviceType"),
		@NamedQuery(name = "Service.findByName", query = "SELECT s FROM Service s WHERE s.name = :name"),
		@NamedQuery(name = "Service.findByClient", query = "SELECT s FROM Service s WHERE s.client = :client"),
		@NamedQuery(name = "Service.findAllPrioritized", query = "SELECT s FROM Service s ORDER BY s.priority ASC")})
public class Service implements Serializable {
	private static final long				serialVersionUID	= 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "Id", nullable = false)
	private Long							id;
	@Column(name = "MTSShortCode", length = 20)
	private String							mTSShortCode;
	@Column(name = "VIPShortCode", length = 20)
	private String							vIPShortCode;
	@Column(name = "TelenorShorCode", length = 20)
	private String							telenorShorCode;
	@Column(name = "MtelShortCode", length = 20)
	private String							mTelShortCode;
	@Column(name = "MTelSenderId", length = 20)
	private String							mTelSenderId;
	@Column(name = "Desctiption", length = 1000)
	private String							desctiption;
	@Column(name = "Sintax", length = 1000)
	private String							sintax;
	@Column(name = "ServiceType")
	private Integer							serviceType;
	@Column(name = "Name", length = 128)
	private String							name;
	@Column(name = "Endpoint", length = 1024)
	private String							endpoint;
	@Column(name = "MTSServiceName", length = 128)
	private String							mtsServiceName;
	@Column(name = "MTSServiceId", length = 128)
	private String							mtsServiceId;
	@Column(name = "TelenorServiceId", length = 128)
	private String							telenorServiceId;
	@Column(name = "Subscription")
	private Boolean							subscription;
	@Column(name = "Priority")
	private Integer							priority;
	@OneToMany(mappedBy = "service")
	private List<OutgoingMessage>			outgoingMessageList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "service", fetch = FetchType.EAGER)
	private List<ServiceChargingCategory>	serviceChargingCategoryList;
	@JoinColumn(name = "ClientId", referencedColumnName = "Id")
	@ManyToOne
	private Client							client;
	@OneToMany(mappedBy = "service")
	private List<IncomingMessage>			incomingMessageList;
	@OneToMany(mappedBy = "service")
	private Set<DistributionList>			distributionListSet;

	public Service() {
	}

	public Service( Long id ) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId( Long id ) {
		this.id = id;
	}

	public String getMTSShortCode() {
		return mTSShortCode;
	}

	public void setMTSShortCode( String mTSShortCode ) {
		this.mTSShortCode = mTSShortCode;
	}

	public String getVIPShortCode() {
		return vIPShortCode;
	}

	public void setVIPShortCode( String vIPShortCode ) {
		this.vIPShortCode = vIPShortCode;
	}

	public String getTelenorShorCode() {
		return telenorShorCode;
	}

	public void setTelenorShorCode( String telenorShorCode ) {
		this.telenorShorCode = telenorShorCode;
	}

	public String getDesctiption() {
		return desctiption;
	}

	public void setDesctiption( String desctiption ) {
		this.desctiption = desctiption;
	}

	public String getSintax() {
		return sintax;
	}

	public Boolean getSubscription() {
		return subscription;
	}

	public void setSubscription( Boolean subscription ) {
		this.subscription = subscription;
	}

	public void setSintax( String sintax ) {
		this.sintax = sintax;
	}

	public Integer getServiceType() {
		return serviceType;
	}

	public void setServiceType( Integer serviceType ) {
		this.serviceType = serviceType;
	}

	public String getName() {
		return name;
	}

	public void setName( String name ) {
		this.name = name;
	}

	public String getMtsServiceId() {
		return mtsServiceId;
	}

	public void setMtsServiceId( String mtsServiceId ) {
		this.mtsServiceId = mtsServiceId;
	}

	public void setEndpoint( String endpoint ) {
		this.endpoint = endpoint;
	}

	public String getEndpoint() {
		return endpoint;
	}

	public List<OutgoingMessage> getOutgoingMessageList() {
		return outgoingMessageList;
	}

	public void setOutgoingMessageList( List<OutgoingMessage> outgoingMessageList ) {
		this.outgoingMessageList = outgoingMessageList;
	}

	public List<ServiceChargingCategory> getServiceChargingCategoryList() {
		return serviceChargingCategoryList;
	}

	public void setServiceChargingCategoryList( List<ServiceChargingCategory> serviceChargingCategoryList ) {
		this.serviceChargingCategoryList = serviceChargingCategoryList;
	}

	public Client getClient() {
		return client;
	}

	public String getMtsServiceName() {
		return mtsServiceName;
	}

	public void setMtsServiceName( String mtsServiceName ) {
		this.mtsServiceName = mtsServiceName;
	}

	public void setClient( Client client ) {
		this.client = client;
	}

	public List<IncomingMessage> getIncomingMessageList() {
		return incomingMessageList;
	}

	public void setIncomingMessageList( List<IncomingMessage> incomingMessageList ) {
		this.incomingMessageList = incomingMessageList;
	}

	public String getTelenorServiceId() {
		return telenorServiceId;
	}

	public void setTelenorServiceId( String telenorServiceId ) {
		this.telenorServiceId = telenorServiceId;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority( Integer priority ) {
		this.priority = priority;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	public Set<DistributionList> getDistributionListSet() {
		return distributionListSet;
	}

	public void setDistributionListSet( Set<DistributionList> distributionListSet ) {
		this.distributionListSet = distributionListSet;
	}

	public String getmTelShortCode() {
		return mTelShortCode;
	}

	public void setmTelShortCode( String mTelShortCode ) {
		this.mTelShortCode = mTelShortCode;
	}

	public void setmTelSenderId( String mTelSenderId ) {
		this.mTelSenderId = mTelSenderId;
	}

	public String getmTelSenderId() {
		return mTelSenderId;
	}

	@Override
	public boolean equals( Object object ) {
		if (!(object instanceof Service)) {
			return false;
		}
		Service other = (Service) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals( other.id ))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.klikmee.sms.core.entities.Service[id=" + id + "]";
	}

}
